<template>
  <div>
    <el-form ref="refForm" :model="formData" :rules="formRules">
      <el-form-item
        label="名称"
        prop="name"
      >
        <el-input v-model="formData.name" placeholder="请输入分组名称" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { $butRequest } from '@/sun-components/SunProcessButRequests.js'
export default {
  name: 'ProcessCommonEvaluationCreateGroup',
  props: {
    source: {
      type: String,
      default: ''
    },
    formData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      formRules: {},
      list: [],
      tabList: [],
      select_index: 0,
      loading: false
    }
  },
  computed: {
    show_createGroup() {
      return this.$parent.$parent.show_createGroup
    }
  },
  watch: {
    show_createGroup: {
      handler: function(show) {
        if (show) {
          this.$set(this.formRules, 'name', [{ required: true, trigger: 'blur', info: '请输入分组名称！', validator: this.$onValidator }])
          this.requestData()
        }
      }
    },
    formData: {
      handler: function(val) {
        this.$refs.refForm.validate(valid => {
          this.$parent.$parent.validate_createGroup = valid
        })
      },
      deep: true
    }
  },
  created() {
    if (this.show_createGroup) {
      this.$set(this.formRules, 'name', [{ required: true, trigger: 'blur', info: '请输入分组名称！', validator: this.$onValidator }])
      this.requestData()
    }
  },
  methods: {
    async requestData() {
      const btn = this.$parent.$parent.set_advance_request
      const objItem = this.$parent.$parent.currentItem
      if (btn.model === 'allocation_expert_and_create_expert_group') {
        $butRequest(btn, objItem)
          .then((response) => {})
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '@/styles/sun-style.scss';
</style>
